<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Transformer模型知识卡片</title>
    <script src="../../assets/js/tailwindcss.js"></script>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&family=Noto+Serif+SC:wght@400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', sans-serif;
            line-height: 1.6;
        }
        .mermaid {
            background-color: transparent !important;
        }
        .highlight-blue {
            color: #3b82f6;
            font-weight: 500;
        }
        .highlight-purple {
            color: #8b5cf6;
            font-weight: 500;
        }
        .grid-card-item {
            transition: all 0.2s ease;
        }
        .grid-card-item:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        }
    </style>
</head>
<body class="bg-gray-50 text-gray-800">
    <div class="max-w-4xl mx-auto my-8 px-4 sm:px-6 lg:px-8">
        <!-- 主卡片容器 -->
        <article class="bg-white rounded-xl shadow-lg overflow-hidden">
            <!-- 头部 -->
            <header class="bg-gradient-to-r from-blue-600 to-purple-600 p-6 sm:p-8 text-white">
                <h1 class="text-3xl sm:text-4xl font-bold mb-2">Transformer模型深度解析</h1>
                <p class="text-xl sm:text-2xl opacity-90">革命性架构如何改变自然语言处理</p>
                <div class="mt-4 flex items-center">
                    <i class="fas fa-brain text-2xl mr-3"></i>
                    <span class="text-sm sm:text-base opacity-80">AI架构 | 深度学习 | NLP突破</span>
                </div>
            </header>
            
            <!-- 主要内容区 -->
            <div class="p-6 sm:p-8">
                <!-- 对比部分 -->
                <section class="mb-10">
                    <h2 class="text-2xl sm:text-3xl font-bold mb-6 flex items-center">
                        <i class="fas fa-balance-scale text-purple-500 mr-3"></i>
                        <span class="highlight-purple">✨ 对比传统模型：Transformer为何更强？</span>
                    </h2>
                    
                    <div class="overflow-x-auto">
                        <table class="w-full border-collapse">
                            <thead>
                                <tr class="bg-gray-100">
                                    <th class="p-3 text-left font-semibold text-gray-700">🔍 能力维度</th>
                                    <th class="p-3 text-left font-semibold text-gray-700">RNN/LSTM</th>
                                    <th class="p-3 text-left font-semibold text-gray-700">Transformer</th>
                                </tr>
                            </thead>
                            <tbody class="divide-y divide-gray-200">
                                <tr>
                                    <td class="p-3 font-medium">📌 信息传递方式</td>
                                    <td class="p-3">像传纸条：必须逐词接力传递信息</td>
                                    <td class="p-3 font-medium text-blue-600">像微信群聊：所有词同时互相交流</td>
                                </tr>
                                <tr class="bg-gray-50">
                                    <td class="p-3 font-medium">📌 长文本处理</td>
                                    <td class="p-3">超过50词易"遗忘"开头内容（梯度消失）</td>
                                    <td class="p-3 font-medium text-blue-600">直接计算任意两词关系："睡觉"可直连"小猫"和"椅子"</td>
                                </tr>
                                <tr>
                                    <td class="p-3 font-medium">🚀 训练速度</td>
                                    <td class="p-3">慢（需顺序计算）</td>
                                    <td class="p-3 font-medium text-blue-600">快300%+（并行计算所有词）</td>
                                </tr>
                                <tr class="bg-gray-50">
                                    <td class="p-3 font-medium">⚠️ 典型限制</td>
                                    <td class="p-3">理解复杂关系困难</td>
                                    <td class="p-3 font-medium text-blue-600">精准捕捉跨句子依赖（如GPT-4支持128K上下文）</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    
                    <div class="mt-6 bg-blue-50 border-l-4 border-blue-500 p-4 rounded-r">
                        <p class="font-medium text-blue-800">
                            <span class="font-bold">💡 关键突破：</span>
                            Transformer通过 <span class="highlight-blue">位置编码（Positional Encoding）</span> 保留词序，类似给每个词发"座位号"，使模型知道"狗咬人"和"人咬狗"的根本区别。
                        </p>
                    </div>
                </section>
                
                <!-- 架构解析部分 -->
                <section>
                    <h2 class="text-2xl sm:text-3xl font-bold mb-6 flex items-center">
                        <i class="fas fa-project-diagram text-blue-500 mr-3"></i>
                        <span class="highlight-blue">✨ 解剖Transformer架构</span>
                    </h2>
                    
                    <div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
                        <!-- 编码器-解码器部分 -->
                        <div class="bg-gray-50 p-6 rounded-lg">
                            <h3 class="text-xl font-bold mb-4 flex items-center">
                                <i class="fas fa-code-branch text-purple-500 mr-2"></i>
                                <span>📌 1. 编码器-解码器协作</span>
                            </h3>
                            
                            <div class="mermaid mb-4">
                                graph LR
                                A[输入句子] --> B(编码器)
                                B --> C{语义空间模型}
                                C --> D(解码器)
                                D --> E[输出结果]
                            </div>
                            
                            <ul class="space-y-3">
                                <li class="flex items-start">
                                    <i class="fas fa-dot-circle text-blue-500 mt-1 mr-2"></i>
                                    <span><span class="font-medium">🔹 编码器：</span>将句子转化为富含关系的语义地图</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-dot-circle text-blue-500 mt-1 mr-2"></i>
                                    <span><span class="font-medium">🔹 解码器：</span>按需提取信息生成新内容（如翻译或续写）</span>
                                </li>
                            </ul>
                        </div>
                        
                        <!-- 层内组件部分 -->
                        <div class="bg-gray-50 p-6 rounded-lg">
                            <h3 class="text-xl font-bold mb-4 flex items-center">
                                <i class="fas fa-layer-group text-purple-500 mr-2"></i>
                                <span>📌 2. 层内组件</span>
                            </h3>
                            
                            <div class="grid grid-cols-1 gap-4">
                                <div class="grid-card-item bg-white p-4 rounded-lg border border-gray-200">
                                    <div class="flex items-start mb-2">
                                        <i class="fas fa-bullseye text-yellow-500 mt-1 mr-2"></i>
                                        <h4 class="font-bold text-lg">🌟 自注意力层</h4>
                                    </div>
                                    <p class="text-gray-700">构建词间关系网，计算所有词对之间的相关性</p>
                                </div>
                                
                                <div class="grid-card-item bg-white p-4 rounded-lg border border-gray-200">
                                    <div class="flex items-start mb-2">
                                        <i class="fas fa-brain text-green-500 mt-1 mr-2"></i>
                                        <h4 class="font-bold text-lg">🌟 前馈网络（MLP）</h4>
                                    </div>
                                    <p class="text-gray-700">深化个体词的理解（类比"个人深度思考"）</p>
                                </div>
                                
                                <div class="grid-card-item bg-white p-4 rounded-lg border border-gray-200">
                                    <div class="flex items-start mb-2">
                                        <i class="fas fa-link text-red-500 mt-1 mr-2"></i>
                                        <h4 class="font-bold text-lg">🛠️ 残差连接</h4>
                                    </div>
                                    <p class="text-gray-700">防止深层训练信息丢失，类似保留初稿修改痕迹</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>
            </div>
            
            <!-- 页脚 -->
            <footer class="bg-gray-100 px-6 py-4 border-t border-gray-200">
                <div class="flex flex-col sm:flex-row justify-between items-center">
                    <div class="flex items-center mb-2 sm:mb-0">
                        <i class="fas fa-lightbulb text-yellow-500 mr-2"></i>
                        <span class="text-sm text-gray-600">AI知识卡片 | 深度学习架构</span>
                    </div>
                    <div class="text-sm text-gray-500">
                        设计版本: V3 | 数据来源: Transformer论文
                    </div>
                </div>
            </footer>
        </article>
    </div>
    
    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>